﻿0<%@ Page Language="C#" AutoEventWireup="true" CodeFile="gendan_made.aspx.cs" Inherits="gendan_made" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link href="App_Themes/css/webstyle.css" rel="stylesheet" />
    <script src="App_Themes/js/jquery-1.8.2.min.js"></script>
    <script src="App_Themes/js/jquery.fxTab.js"></script>
    <title>定制跟单</title>
    <script src="js/jquery.fancybox.pack.js"></script>
    <link href="js/jquery.fancybox.css" rel="stylesheet" />
    <script>
        function login() {
            $("#boxgendan .01").fancybox({
                'fitToView': false,
                'autoSize': false,
                'width': '400px',
                'height': '270px',
                'type': 'iframe',
                'padding': 0,
                'wrapCSS': 'blue_wp',

                "iframe": {
                    scrolling: 'hidden'
                }

            });
            $("#boxgendan .01").trigger('click');
        }
        //预付固定金额
        function dingzhis() {
            var loginUserInfo = $('#lognUserInfo').val();

            var url = "message.aspx?userID=" + loginUserInfo + "&dingdanID=<%=id%>";
            if (jQuery('#YCCS').val() < 1 || (jQuery('#YCCS').val() > 100)) {
                alert("认购次数不在范围内！");
                return;
            }
            if (jQuery('#YCCS').val() == "") {
                alert("认购次数不在范围内！");
                return;
            }
            if ((jQuery('#YFGDmoney').val() < 2 || (jQuery('#YFGDmoney').val()) > 100000)) {
                alert("认购金额不在范围内！");
                return;
            }

            if (jQuery('#YFGDmoney').val() == "") {
                alert("认购金额不在范围内！");
                return;
            }
            var reg = new RegExp("^[0-9]*$");  //判断是否是正整数；
            var userbuy = document.getElementById("YFGDmoney").value;
            if (!reg.test(userbuy)) {
                alert("请您填写购买金额!");
                return;
            }

            $.getJSON(url, '', function (data) {
                var obj = eval(data);
                var dingzhiJE = obj.JE;//总金额
                var dingzhigdRS = obj.GDRS;//跟单人数
                var dingzhiFAJE = obj.FAJE;//方案金额
                var dingzhiFAYE = obj.FAYE;//方案余额
                var dingzhiFADJ = obj.FADJJE;
                var jine = $("#YFGDmoney").val();//金额
                var shuliang = $("#YCCS").val();//次数
                var money = jine * shuliang;  //计算出的当前金额
                if (money < 2) {

                    alert("跟单金额不能小于2元");
                    return;
                }
                if (parseFloat(money) > parseFloat(dingzhiFAJE)) {
                    alert("跟单金额不能超过方案金额");
                    return;
                }

                if (parseFloat(money) > parseFloat(dingzhiFAYE)) { //如果方案金额为0.他也能定制成功
                    //剩余金额,传值到Cmeber里面进行判断
                    money = dingzhiFAYE;
                }
                var kyje = parseFloat(dingzhiJE) - parseFloat(dingzhiFADJ);//总金额-方案冻结金额=可用金额(如果当前金额小于可用金额，进入充值界面)
                if (parseInt(kyje) < parseInt(money))  //kyje可用金额
                {        //扣除金额=当前的钱-可用的钱
                    var czje = money - kyje; //
                    alert("当前账户余额不足，请先进行充值！");
                    window.parent.location.href = 'per_will_deposit.aspx?t=' + czje;
                }

                //t:yfgd 预付固定扣款   user_id:跟单ID  faje：方案金额  
                <%-- jQuery('form').attr("action", "Ajax/CMember.ashx?t=yfgd&fangAnId=<%=id%>&faje=" + dingzhiFAJE + "&user_id=" + loginUserInfo
                                 + "&customoney=" + money + "&YFGDmoney=" + jQuery('#YFGDmoney').val()
                                 + "&YCCS=" + jQuery('#YCCS').val()).submit();--%>
                jQuery('form').attr("action", "Ajax/CMember.ashx?t=GenDanMade&fangAnId=<%=id%>&faje=" + dingzhiFAJE + "&user_id=" + loginUserInfo
                                 + "&customoney=" + money + "&YFGDmoney=" + jQuery('#YFGDmoney').val()
                                 + "&YCCS=" + jQuery('#YCCS').val() + "&fkfs=1&fbfb=1").submit();


            });

        }
        //预付--按百分比扣款
        function dingzhiYFB() {
            var loginUserInfo = $('#lognUserInfo').val();
            if (jQuery('#YFBFBmoney').val() < 1) {
                alert("认购金额不在范围内！");
                return;
            }
            if ((jQuery('#YFBFBmoney').val()) == "") {
                alert("认购金额不在范围内！");
                return;
            }
            if (jQuery('#YFBL').val() < 1 || (jQuery('#YFBL').val() > 100)) {
                alert("认购百分比不在范围内！");
                return;
            }
            if (jQuery('#YFBL').val() == "") {
                alert("认购百分比不在范围内！");
                return;

            }
            if (jQuery('#YFGDCS').val() == "") {
                alert("认购次数不在范围内！");
                return;
            }
            if (jQuery('#YFGDCS').val() < 1 || (jQuery('#YFGDCS').val() > 100)) {
                alert("认购次数不在范围内！");
                return;
            }
            var reg = new RegExp("^[0-9]*$"); //判断是否是正整数；
            var userbuy = document.getElementById("YFBFBmoney").value;
            if (!reg.test(userbuy)) {
                alert("请您填写购买金额!");
                return;
            }
            var url = "message.aspx?userID=" + loginUserInfo + "&dingdanID=<%=id%>";
            $.getJSON(url, '', function (data) {
                var obj = eval(data);
                var dingzhiJE = obj.JE;//总金额
                var dingzhigdRS = obj.GDRS;//跟单人数
                var dingzhiFAJE = obj.FAJE;//方案金额
                var dingzhiFAYE = obj.FAYE;//方案余额
                var dingzhiFADJ = obj.FADJJE;
                var yfbf = $("#YFBL").val(); //预付百分比
                yfbfb = (yfbf / 100);
                var yfje = $("#YFBFBmoney").val(); //最多不能超过的金额
                var yfgd = $("#YFGDCS").val(); //预付跟单次数
                var moneys = (yfbfb * dingzhiFAJE * yfgd);
                var money = moneys.toFixed(2);//四舍五入，保留两位小数

                if (money < 2) {

                    alert("跟单金额不能小于2元");
                    return;
                }

                if (yfbf > 100) {
                    alert("认购百分比不能超过100%");
                    return;
                }
                if (parseFloat(money) > parseFloat(dingzhiFAJE)) {

                    alert("跟单金额不能超过方案金额");
                    return;
                }

                if (parseFloat(money) > parseFloat(yfje)) {
                    //money = yfje;
                    alert("认购最多不超过" + yfje);
                    return;
                }
                var kcje = parseFloat(dingzhiJE) - parseFloat(dingzhiFADJ);//总金额-方案冻结金额=可用金额(如果当前金额小于可用金额，进入充值界面)
                if (parseInt(kcje) < parseInt(money))  //kyje可用金额
                {        //扣除金额=当前的钱-可用的钱
                    var czje = money - kcje; //
                    alert("当前账户余额不足，请先进行充值！");
                    window.parent.location.href = 'per_will_deposit.aspx?t=' + czje;
                }

                if (parseFloat(money) > parseFloat(dingzhiFAYE)) { //如果方案金额为0.他也能定制成功
                    //剩余金额,传值到Cmeber里面进行判断
                    money = dingzhiFAYE;
                }
                if (parseFloat(money) > parseFloat(yfje)) {  //当前金额如果大于可用金额，那么就存可用金额
                    alert("认购最多不超过" + yfje);
                    return;
                }
                <%-- jQuery('form').attr("action", "Ajax/CMember.ashx?t=yfbfb&fangAnId=<%=id%>&faje=" + dingzhiFAJE + "&user_id=" + loginUserInfo
                                                        + "&customoney=" + moneys + "&YFBL=" + jQuery('#YFBL').val()
                                                        + "&YFBFBmoney=" + jQuery('#YFBFBmoney').val()
                                                        + "&YFGDCS=" + jQuery('#YFGDCS').val()).submit();--%>
                jQuery('form').attr("action", "Ajax/CMember.ashx?t=GenDanMade&fangAnId=<%=id%>&faje=" + dingzhiFAJE + "&user_id=" + loginUserInfo
                                                       + "&customoney=" + moneys + "&YFBL=" + jQuery('#YFBL').val()
                                                       + "&YFBFBmoney=" + jQuery('#YFBFBmoney').val()
                                                       + "&YFGDCS=" + jQuery('#YFGDCS').val() + "&fkfs=1&fbfb=2").submit();
            });

        }
        //实时扣款--按固定金额
        function dingzhiSK() {
            var loginUserInfo = $('#lognUserInfo').val();
            if (jQuery('#SKGDmoney').val() < 2 || (jQuery('#SKGDmoney').val() > 100000)) {
                alert("请正确填写认购金额！");
                return;
            }
            if ((jQuery('#SKGDmoney').val()) == "") {
                alert("请正确填写认购金额！");
                return;
            }

            var reg = new RegExp("^[0-9]*$"); //判断是否是正整数；
            var userbuy = document.getElementById("SKGDmoney").value;
            if (!reg.test(userbuy)) {
                alert("请您填写购买金额!");
                return;
            }

            var url = "message.aspx?userID=" + loginUserInfo + "&dingdanID=<%=id%>";
            $.getJSON(url, '', function (data) {
                var obj = eval(data);
                var dingzhiJE = obj.JE;//总金额
                var dingzhigdRS = obj.GDRS;//跟单人数
                var dingzhiFAJE = obj.FAJE;//方案金额
                var dingzhiFAYE = obj.FAYE;//方案余额
                var dingzhiFADJ = obj.FADJJE;
                var money = $("#SKGDmoney").val();
                if (money < 2) {

                    alert("跟单金额不能小于2元");
                    return;
                }
                if (parseFloat(money) > parseFloat(dingzhiFAJE)) {

                    alert("跟单金额不能超过方案金额");
                    return;
                }


                if (parseFloat(money) > parseFloat(dingzhiFAYE)) { //如果方案金额为0.他也能定制成功
                    //剩余金额,传值到Cmeber里面进行判断
                    money = dingzhiFAYE;
                }
                var kyje = parseFloat(dingzhiJE) - parseFloat(dingzhiFADJ);//总金额-方案冻结金额=可用金额(如果当前金额小于可用金额，进入充值界面)
                if (parseInt(kyje) < parseInt(money))  //kyje可用金额
                {        //扣除金额=当前的钱-可用的钱
                    var czje = money - kyje; //
                    alert("当前账户余额不足，请先进行充值！");
                    window.parent.location.href = 'per_will_deposit.aspx?t=' + czje;
                }


                //:jd方案进度  faje方案总金额
                <%--    jQuery('form').attr("action", "Ajax/CMember.ashx?t=sfgd&&fangAnId=<%=id%>&faje=" + dingzhiFAJE + "&user_id=" + loginUserInfo
                                  + "&customoney=" + money).submit();--%>
                jQuery('form').attr("action", "Ajax/CMember.ashx?t=GenDanMade&&fangAnId=<%=id%>&faje=" + dingzhiFAJE + "&user_id=" + loginUserInfo
                              + "&customoney=" + money + "&fkfs=2&fbfb=1").submit();
            });
        }
        //实时扣款--固定百分比
        function dingzhiSKBF() {

            var loginUserInfo = $('#lognUserInfo').val();

            if (jQuery('#SKBFmoney').val() < 1) {
                alert("请正确填写认购金额！");
                return;
            }

            if (jQuery('#SKBFmoney').val() == "") {
                alert("请正确填写认购金额！");
                return;
            }

            if (jQuery('#SFbfb').val() < 1 || (jQuery('#SFbfb').val() > 100)) {
                alert("请正确填写认购比例！");
                return;
            }

            if (jQuery('#SFbfb').val() == "") {
                alert("请正确填写认购比例！");
                return;
            }

            var reg = new RegExp("^[0-9]*$"); //判断是否是正整数；
            var userbuy = document.getElementById("SKGDmoney").value;
            if (!reg.test(userbuy)) {
                alert("请您填写购买金额!");
                return;
            }
            var url = "message.aspx?userID=" + loginUserInfo + "&dingdanID=<%=id%>";
            $.getJSON(url, '', function (data) {
                var obj = eval(data);
                var dingzhiJE = obj.JE;//总金额
                var dingzhigdRS = obj.GDRS;//跟单人数
                var dingzhiFAJE = obj.FAJE;//方案金额
                var dingzhiFAYE = obj.FAYE;//方案余额
                var dingzhiFADJ = obj.FADJJE;
                var skje = $("#SFbfb").val();//购买比例
                var sf = $("#SKBFmoney").val();
                if (skje > 100) {
                    alert("认购比例不能超过100%");
                    return;
                }
                var moneyfixe = skje / 100;
                var allmoeny = (moneyfixe * dingzhiFAJE);
                var money = allmoeny.toFixed(2);//四舍五入，保留两位小数
                if (parseFloat(money) > parseFloat(sf)) {

                    alert("认购最多不超过" + sf);
                    return;
                }
                if (money < 2) {

                    alert("跟单金额不能小于2元");
                    return;
                }
                //四舍五入，保留两位小数

                if (parseFloat(money) > parseFloat(dingzhiFAJE)) {

                    alert("跟单金额不能超过方案金额");
                    return;
                }



                if (parseFloat(money) > parseFloat(dingzhiFAYE)) { //如果方案金额为0.他也能定制成功
                    //剩余金额,传值到Cmeber里面进行判断
                    money = dingzhiFAYE;
                }

                var kyje = parseFloat(dingzhiJE) - parseFloat(dingzhiFADJ);//总金额-方案冻结金额=可用金额(如果当前金额小于可用金额，进入充值界面)

                if (parseInt(kyje) < parseInt(money))  //kyje可用金额
                {        //扣除金额=当前的钱-可用的钱
                    //var czje = money - dingzhiJE; //
                    var czje = money - kyje; //
                    alert("当前账户余额不足，请先进行充值！");
                    window.parent.location.href = 'per_will_deposit.aspx?t=' + czje;
                }

                // 判断条件，当前金额是小于余额，还是，剩余金额，用&&还是用||
                <%--jQuery('form').attr("action", "Ajax/CMember.ashx?t=sfbfb&fangAnId=<%=id%>&faje=" + dingzhiFAJE + "&user_id=" + loginUserInfo
                                            + "&customoney=" + money + "&SFbfb=" + jQuery('#SFbfb').val()
                                            + "&SKBFmoney=" + jQuery('#SKBFmoney').val()).submit();--%>
                jQuery('form').attr("action", "Ajax/CMember.ashx?t=GenDanMade&fangAnId=<%=id%>&faje=" + dingzhiFAJE + "&user_id=" + loginUserInfo
                                            + "&customoney=" + money + "&SFbfb=" + jQuery('#SFbfb').val()
                                            + "&SKBFmoney=" + jQuery('#SKBFmoney').val() + "&fkfs=2&fbfb=2").submit();

            });
        }

    </script>
</head>
<body>
    <form id="form1" runat="server">
        <input id="lognUserInfo" type="hidden" value="<%=User_Id%>" />

        <!-- 弹框 -->
        <div class="dz_tan">
            <% if (LotteryUserDt != null)
                {
                    for (int i = 0; i < LotteryUserDt.Rows.Count; i++)
                    {%>
            <div class="dz_t_top">
                <span class="fl">
                    <img src="<%=LotteryUserDt.Rows[i]["photo"]==DBNull.Value? "images/dzgd.png":LotteryUserDt.Rows[i]["photo"]%>" /></span>
                <table width="370" border="0" cellspacing="0" cellpadding="0" class="fr dz_t_table">
                    <tr>
                        <td height="24" align="left" valign="middle">用户名：<span class="dz_t_text"><%=LotteryUserDt.Rows[i]["nickname"] %></span></td>
                        <td align="left" valign="middle">定制彩种：<b><%=LotteryUserDt.Rows[i]["LotteryType"].ToString() == "1" ? "双色球"
                                : (LotteryUserDt.Rows[i]["LotteryType"].ToString() == "2" ? "大乐透"
                                          : (LotteryUserDt.Rows[i]["LotteryType"].ToString() == "3" ? "排列三"
                                                    : (LotteryUserDt.Rows[i]["LotteryType"].ToString() == "4" ? "排列五"
                                                              : (LotteryUserDt.Rows[i]["LotteryType"].ToString() == "5" ? "福彩3D"
                                                                        :( LotteryUserDt.Rows[i]["LotteryType"].ToString() == "6" ? "七星彩"
                                                                                  : (LotteryUserDt.Rows[i]["LotteryType"].ToString() == "7" ? "七乐彩" : ""))))))%></b></td>
                    </tr>
                    <tr>
                        <td height="24" align="left" valign="middle">战绩：<span class="dz_t_icon1"><%=ViewModelLevel(Convert.ToInt64(LotteryUserDt.Rows[i]["modellevel"])) %></span></td>
                        <td align="left" valign="middle">跟单人数：<b><%=(chakan_count(id) )%>人(剩余<%=1000-(chakan_count(id) )%>人)</b></td>
                    </tr>
                    <tr>
                        <td height="24" align="left" valign="middle">累计中奖：<span class="dz_text"><%=LotteryUserDt.Rows[i]["winTotal"] %></span>元</td>
                        <td align="left" valign="middle">&nbsp;</td>
                    </tr>
                </table>
                <div class="cl"></div>
            </div>

            <%}
                }

            %>
            <div class="dz_t_mid">
                <style type="text/css">
                    .fxui-tab {
                        height: 320px;
                    }

                        .fxui-tab .fxui-tab-hand {
                            background: #fff;
                            color: #4e4e4e;
                            border: solid 1px #d9d9d9;
                            border-left: solid 1px #d9d9d9;
                            text-align: center;
                            height: 37px;
                            line-height: 37px;
                            color: #4e4e4e;
                            font-size: 13px;
                            margin-left: -1px;
                            font-weight: bold;
                        }

                        .fxui-tab .fxui-tab-tit {
                            width: 50%;
                            display: block;
                            cursor: pointer;
                            float: left;
                            text-align: center;
                        }

                        .fxui-tab .fxui-tab-hand .curr {
                            background: #0195df;
                            color: #fff;
                        }

                        .fxui-tab .fxui-tab-nav {
                        }

                    .fxui-tab1 {
                    }

                        .fxui-tab1 .fxui-tab-hand1 {
                            background: #fff;
                            color: #4e4e4e;
                            margin: 0 5px;
                            color: #4e4e4e;
                        }

                        .fxui-tab1 .fxui-tab-tit1 {
                            display: block;
                            float: left;
                            cursor: pointer;
                            text-align: center;
                            padding: 0 5px;
                        }

                        .fxui-tab1 .fxui-tab-hand1 .curr {
                            color: #fff;
                            background: #9fc7e5;
                        }

                        .fxui-tab1 .fxui-tab-nav1 {
                        }
                </style>

                <div class="fxui-tab">
                    <div class="fxui-tab-hand">
                        <span class="fxui-tab-tit" id="yfkk">预付扣款</span>
                        <span class="fxui-tab-tit" id="sskk">实时扣款</span>
                        <div class="cl"></div>
                    </div>
                    <div class="fxui-tab-nav">
                        <div class="dz_t_nr">


                            <div class="fxui-tab1">
                                <div style="height: 20px; line-height: 20px;">
                                    <b class="fl">定制方式：</b>
                                    <div class="fxui-tab-hand1 fl" style="padding: 0;">
                                        <span class="fxui-tab-tit1">按固定金额</span> <span class="fl">丨</span>

                                        <span class="fxui-tab-tit1">按固定百分比</span>
                                        <div class="cl"></div>
                                    </div>
                                </div>
                                <div class="fxui-tab-nav1">

                                    <div>
                                        每个方案认购：
                                        <input type="text" class="dz_t_bd1" id="YFGDmoney" runat="server" />
                                        元，至少2元
                                    </div>
                                    <div>
                                        设置跟单次数：
                                        <input type="text" class="dz_t_bd1" id="YCCS" runat="server" />
                                        次， 最多100次，成功1个算1次
                                    </div>

                                    <div class="dz_t_line">
                                        <div class="dz_t_text2">[提示:冻结金额不可支付]</div>
                                    </div>
                                    <div class="tc">
                                        <input type="button" id="ljdz" value="立即定制" onclick="dingzhis();" class="dz_t_btn" />
                                    </div>
                                </div>
                                <div class="fxui-tab-nav1">
                                    <div>
                                        每次认购比例：  
                                    <input type="text" class="dz_t_bd1" id="YFBL" />
                                        %&nbsp;&nbsp;&nbsp; 每次认购最多不超过<input type="text" class="dz_t_bd1" id="YFBFBmoney" />元
                                    </div>
                                    <div>
                                        设置跟单次数：
                                    <input type="text" class="dz_t_bd1" id="YFGDCS" />
                                        次，最多100次，成功一个算一次
                                    </div>

                                    <div class="dz_t_line">
                                        <div class="dz_t_text2">[提示:冻结金额不可支付]</div>
                                    </div>
                                    <div class="tc">
                                        <input type="button" value="立即定制" onclick="dingzhiYFB()" class="dz_t_btn" />
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="fxui-tab-nav">

                        <div class="dz_t_nr">

                            <div class="fxui-tab1">
                                <div style="height: 20px; line-height: 20px;">
                                    <b class="fl">定制方式：</b>
                                    <div class="fxui-tab-hand1 fl" style="padding: 0;">
                                        <span class="fxui-tab-tit1">按固定金额</span> <span class="fl">丨</span><span class="fxui-tab-tit1">按固定百分比</span>
                                        <div class="cl"></div>
                                    </div>
                                </div>

                                <div class="fxui-tab-nav1">
                                    <div>
                                        每个方案认购：
                                    <input type="text" class="dz_t_bd1" id="SKGDmoney">
                                        元，至少2元
                                    </div>


                                    <div class="dz_t_line">
                                        <div class="dz_t_text2">[提示:不支持红包支付]</div>
                                    </div>
                                    <div class="tc">
                                        <input type="button" value="立即定制" onclick="dingzhiSK();" class="dz_t_btn" />
                                    </div>
                                </div>

                                <div class="fxui-tab-nav1">
                                    <div>
                                        每次认购比例：
                                    <input type="text" class="dz_t_bd1" id="SFbfb">
                                        %&nbsp;&nbsp;&nbsp; 每次认购最多不超过<input type="text" class="dz_t_bd1" id="SKBFmoney">元
                                    </div>
                                    <div class="dz_t_line">
                                        <div class="dz_t_text2">[提示:不支持红包支付]</div>
                                    </div>
                                    <div class="tc">
                                        <input type="button" value="立即定制" onclick="dingzhiSKBF()" class="dz_t_btn" />
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="dz_t_text1">
                <b>注意事项：</b><br>
                1、用户方案每次只能定制一次。<br>
                2、可购金额不能大于您的设定金额。<br>
                3、当使用百分比跟单时换算后认购金额大于用户所设置的金额，则跟单失败。<br>
                4、实时扣款不用预付定制跟单金额，只需账户余额满足每次认购金额即可跟单。<br>
                5、预付扣款定制成功后，将冻结要扣除的金额，如果成功将会从账户扣除，如果失败则账户金额不变。<br />
                6、如果当前账户金额不足，则跳转到充值页面。<br />
                7、发起方案人不可以定制当前期的方案。
            </div>
        </div>


        <script type="text/javascript">
            $('.fxui-tab').fxuiTab();
        </script>
        <script type="text/javascript">
            $('.fxui-tab1').fxuiTab1();
        </script>
    </form>

</body>
</html>
